package top.xlq.mydb.backend.parser;

import java.nio.Buffer;
import java.nio.ByteBuffer;

public class Parser {

    public static long parserLong(byte[] arr) {
        ByteBuffer buffer = ByteBuffer.wrap(arr, 0, 8);
        return buffer.getLong();
    }

    public static byte[] parserLong2Byte(Long value) {
        return ByteBuffer.allocate(Long.SIZE / Byte.SIZE).putLong(value).array();
    }

    public static short parserShort(byte[] arr) {
        ByteBuffer buffer = ByteBuffer.wrap(arr, 0, 2);
        return buffer.getShort();
    }

    public static byte[] parserShort2Byte(short value) {
        return ByteBuffer.allocate(Short.SIZE / Byte.SIZE).putShort(value).array();
    }


}
